package main

import "fmt"

func main() {
	ch := make(chan int, 3) //存满3个元素前，不会阻塞
	fmt.Println("len = ", len(ch), "cap = ", cap(ch))

	go func() {
		for i := 0; i < 8; i++ {
			ch <- i
			fmt.Println("子go程：i = ", i)
		}
	}()

	for i := 0; i < 8; i++ {
		num := <-ch
		fmt.Println("主go程读，i = ", num)
	}
}
